<template>
  <div class="text-container" :style="{ backgroundColor: backgroundColor }">
    <el-form label-position="left" label-width="90px">
      <el-form-item :label="label + ':'">
        <el-text class="text" size="large" tag="b">{{ name }}</el-text>
      </el-form-item>
    </el-form>
  </div>
</template>

<script lang="ts">
import { defineComponent, onMounted, ref, computed } from "vue";
export default defineComponent({
  name: "TextNode",
  props: {
    label: {
      type: String,
      required: true,
    },
    name: {
      type: String,
      required: true,
    },
    status: {
      type: Boolean,
      default: null,
    },
  },
  setup(props) {
    const backgroundColor = computed(() => {
      if (props.status === null) {
        return "#badbf8"; // 默认颜色
      } else if (props.status === false) {
        return "#f44336"; // 红色
      } else if (props.status === true) {
        return "#4caf50"; // 绿色
      }
      return "#badbf8";
    });
    onMounted(() => {});
    return { backgroundColor };
  },
});
</script>

<style scoped>
.text-container {
  margin-top: 20px;
  width: 220px;
  height: 30px;
  padding: 10px;
  cursor: pointer;
  background-color: #badbf8;
  border-radius: 5px; /* 可选：添加圆角 */
  border: 1px solid #000; /* 添加黑色边框 */
  color: #000; /* 字体颜色改为黑色 */
  transition: background-color 0.3s; /* 添加过渡效果 */
  .text {
    font-size: 16px;
    font-weight: 600;
  }
}

.option:hover {
  background-color: #f0f0f0; /* 可选：添加悬停效果 */
}

.indicator {
  width: 20px; /* 指示器的宽度 */
  height: 20px; /* 指示器的高度 */
  border-radius: 50%;
  margin-right: 10px; /* 指示器与文本之间的间距 */
}
</style>
